#region License Information
// Copyright (c) 2005 - 2009, Allan Spartacus Mangune (allan@owlpal.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, 
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list 
//   of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice, this list of 
//   conditions and the following disclaimer in the documentation and/or other materials provided 
//   with the distribution.
//
// * Neither the name of Owlpal nor the names of its contributors may be used to endorse or 
//   promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
// FITNESS FOR AllowHtmlInComment PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using Owlpal.Blogs.Repositories;

namespace Owlpal.Blogs.Models
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Entry
    {
        #region Members
        private Guid id;
        private Blog blog;
        private MembershipUser creator;
        private MembershipUser updator; 
        private string linkName; 
        private string title; 
        private string excerpt; 
        private string text; 
        private bool isCommentNotificationEnabled; 
        private bool isExcerptSyndicationEnabled; 
        private bool isCommentingAllowed; 
        private bool isPingingAllowed; 
        private bool isTrackbackAllowed; 
        private DateTime flightStartDate; 
        private DateTime flightEndDate; 
        private DateTime syndicationDate; 
        private string status; 
        private string commentStatus;
        private bool isDeleted; 
        private DateTime creationDate;
        private DateTime dateUpdated;
        private Guid updatedBy;
        private int commentCount;
        private string blogName;
        private List<Tag> tags;
        private List<Category> categories;
        #endregion

        #region Properties
        public Blog Blog
        {
            get { return this.blog; }
            set { this.blog = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public int CommentCount
        {
            get { return this.commentCount; }
            set { this.commentCount = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string BlogName
        {
            get { return this.blogName; }
            set { this.blogName = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public List<Tag> Tags
        {
            get { return this.tags; }
            set { this.tags = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public List<Category> Categories
        {
            get { return this.categories; }
            set { this.categories = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public Guid ID 
        { 
            get { return this.id; } 
            set { this.id = value; } 
        }

        /// <summary>
        /// 
        /// </summary>
        public MembershipUser Creator 
        { 
            get { return this.creator; } 
            set { this.creator = value; } 
        }
        
        /// <summary>
        /// 
        /// </summary>
        public string LinkName 
        { 
            get { return this.linkName; } 
            set { this.linkName = value; } 
        }
        
        /// <summary>
        /// 
        /// </summary>
        public string Title 
        { 
            get { return this.title; }
            set { this.title = value; } 
        }
        
        /// <summary>
        /// 
        /// </summary>
        public string Excerpt
        {
            get { return this.excerpt; }
            set { this.excerpt = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string Text
        {
            get { return this.text; }
            set { this.text= value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public bool IsCommentNotificationEnabled
        {
            get { return this.isCommentNotificationEnabled; }
            set { this.isCommentNotificationEnabled = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public bool IsExcerptSyndicationEnabled
        {
            get { return this.isExcerptSyndicationEnabled; }
            set { this.isExcerptSyndicationEnabled = value; }
        }
        
        /// <summary>
        /// 
        /// </summary>
        public bool IsCommentingAllowed
        {
            get { return this.isCommentingAllowed; }
            set { this.isCommentingAllowed = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public bool IsPingingAllowed
        {
            get { return this.isPingingAllowed; }
            set { this.isPingingAllowed = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public bool IsTrackbackAllowed
        {
            get { return this.isTrackbackAllowed; }
            set { this.isTrackbackAllowed = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public DateTime FlightStartDate
        {
            get { return this.flightStartDate; }
            set { this.flightStartDate = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public DateTime FlightEndDate
        {
            get { return this.flightEndDate; }
            set { this.flightEndDate = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public DateTime SyndicationDate
        {
            get { return this.syndicationDate; }
            set { this.syndicationDate = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string Status
        {
            get { return this.status; }
            set { this.status = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string CommentStatus
        {
            get { return this.commentStatus; }
            set { this.commentStatus = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public DateTime CreationDate
        {
            get { return this.creationDate; }
            set { this.creationDate = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public DateTime DateUpdated
        {
            get { return this.dateUpdated; }
            set { this.dateUpdated = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public MembershipUser Updator
        {
            get { return this.updator; }
            set { this.updator = value; }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Creates a Entry.
        /// </summary>
        /// <returns>Returns the status of the Add operation.</returns>
        public AddEntryStatus Save()
        {
            AddEntryStatus status = AddEntryStatus.UnknownError;
            IEntryRepository repository = new EntryRepository();
            this.dateUpdated = DateTime.MinValue;
            this.creationDate = DateTime.Now;
            this.id = Guid.NewGuid();
            status = repository.SaveEntry(this);
            return status;
        }

        /// <summary>
        /// Updates the Entry.
        /// </summary>
        /// <returns>Returns the status of the Edit operation.</returns>
        public EditEntryStatus Edit()
        {
            EditEntryStatus status = EditEntryStatus.UnknownError;
            return status;
        }

        /// <summary>
        /// Marks the record of Entry as deleted. 
        /// </summary>
        /// <returns>Returns the status of the Delete operation.</returns>
        public static DeleteEntryStatus Delete(Guid id)
        {
            DeleteEntryStatus status = DeleteEntryStatus.UnknownError;
            return status;
        }

        /// <summary>
        /// Permanently remove the record from the database.
        /// </summary>
        /// <returns>Returns the status of the Remove operation.</returns>
        public RemoveEntryStatus Remove(Guid id)
        {
            RemoveEntryStatus status = RemoveEntryStatus.UnknownError;
            return status;
        }

        /// <summary>
        /// Loads a Entry based on its unique ID.
        /// </summary>
        /// <param name="unitPrice">The unique ID of the Entry.</param>
        /// <returns>The Entry.</returns>
        public static Entry Find(System.Guid id)
        {
            return null;
        }
        
        /// <summary>
        /// Loads a collection of Entries based on BlogID attribute.
        /// </summary>
        /// <param name="unitPrice">The BlogID attribute.</param>
        /// <returns>AllowHtmlInComment collection of Entries.</returns>
        public static List<Entry> FindAllByBlogID(System.Guid blogID)
        {
            return null;
        }

        /// <summary>
        /// Loads a collection of Entries based on BlogID attribute.
        /// </summary>
        /// <param name="unitPrice">The BlogID attribute.</param>
        /// <returns>AllowHtmlInComment collection of Entries.</returns>
        public static List<Entry> FindAllByBlogID(System.Guid blogID, int pageIndex, int pageSize)
        {
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="take"></param>
        /// <returns></returns>
        public static List<Entry> FindAll(int take)
        {
            List<Entry> entries = new List<Entry>();
            return entries;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static List<Entry> FindAll(int pageIndex, int pageSize)
        {
            List<Entry> entries = new List<Entry>();
            return entries;
        }

        /// <summary>
        /// Loads a collection of Entries.
        /// </summary>
        /// <param name="products">The Entries object that will hold the collection of Entries.</param>
        /// <param name="query">The query executed against the database.</param>
        private static List<Entry> LoadEntries(IQueryable<Entry> query)
        {
            List<Entry> entries = new List<Entry>();
            return entries;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="blogName"></param>
        /// <returns></returns>
        public static List<Entry> FindAll(string blogName)
        {
            List<Entry> entries = new List<Entry>();
            return entries;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="categoryID"></param>
        /// <returns></returns>
        public static List<Entry> FindAll(Guid categoryID)
        {
           return null;
        }
        #endregion
    }
}